﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProtoBuf.Message;
using UnityEngine;

namespace UI
{
    public class ShowCCGift : MonoBehaviour
    {
        public SimpleGrid grid;
        public UIScrollView scrollView;
        public GameObject iconPrefab;

        public UIActivityContinueChargeGift uiActivity;
        ActivityItem curActivityItem;
        
        public void SetData(ActivityItem item)
        {
            curActivityItem = item;
        }
        public void Show()
        {
            gameObject.SetActive(true);
            Refresh();
        }
        public void Hide()
        {
            foreach (var item in grid.childs)
            {
                Destroy(item);
            }
            grid.childs.Clear();
            gameObject.SetActive(false);
        }
        public void Refresh()
        {
            foreach (var item in curActivityItem.rewardList)
            {
                GameObject obj = GameObject.Instantiate(iconPrefab);
                obj.SetActive(true);
                obj.GetComponent<ContinueGiftGetItem>().Init(item);
                grid.AddChild(obj);
            }

        }


    }
}
